﻿using BCCommon;
using BCCommon.Enums;
using BCCommon.PaymentEnums;
using BCData.Common.Payment.WxPayBill;
using BCDto.Common.Payment.WeChatPayBill;
using BCDto.Common.Payment.WeChatPayBill.WxPayBillDetail;
using BCDto.Common.Payment.WeChatPayBill.WxPayBillStatistics;
using BCEntity.Common.Payment.WeChatPayBill.WxPayBillDetail;
using BCEntity.Common.Payment.WeChatPayBill.WxPayBillStatistics;
using BCService.Utils;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BCService.Common.Payment.PaymentBill.WxPayBill
{
    public class WxPayBillService:IWxPayBillService
    {
        private readonly IConfiguration configuration;
        private readonly IWxPayBillData wxPayBillData;
        private static Dictionary<string, string> bankDic = new Dictionary<string, string>();
        private static Dictionary<string, string> accountDic = new Dictionary<string, string>();

        public WxPayBillService(IConfiguration configuration,
            IWxPayBillData wxPayBillData)
        {
            this.configuration = configuration;
            this.wxPayBillData = wxPayBillData;
            if (bankDic.Count == 0)
            {
                GetWxPayBankName();
                InitAccountInfo();
            }
        }
        public WxPayBillDto Insert(DateTime billDate, WeChatBillType billType, string result)
        {
            WxPayBillDto billDto = new WxPayBillDto();
            List<WxPayBillDetailEntity> billDetailResult = GetBillResult(result, billDate, billType, out WxPayBillStatisticsEntity billStatistics);
            billDto = new WxPayBillDto
            {
                Details = billDetailResult.As<List<WxPayBillDetailDto>>(),
                BillStatistics = billStatistics.As<WxPayBillStatisticsDto>()
            };
            if (!this.wxPayBillData.SomeDayBillExists(billDate,billType).GetAwaiter().GetResult())
            {
                this.wxPayBillData.Insert(billDetailResult, billStatistics).GetAwaiter().GetResult();
            }
            return billDto;
        }

        public PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto> GetSomeDayBill(DateTime tradeDate, WeChatBillType weChatBillType,int pageIndex,int pageSize)
        {
            var data = this.wxPayBillData.GetSomeDayBill(tradeDate, weChatBillType).GetAwaiter().GetResult();
            var result = new PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto>
            {
                Items = data.Item1.Skip((pageIndex-1)*pageSize).Take(pageSize).As<List<WxPayBillDetailDto>>(),
                Count = data.Item1.Count(),
                PageIndex = pageIndex,
                PageSize = pageSize,
                Statistics = data.Item2.As<WxPayBillStatisticsDto>()
            };
            return result;
        }

        public PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto> GetSomeMonthBill(int year, int month, WeChatBillType weChatBillType, int pageIndex, int pageSize)
        {

            var data = this.wxPayBillData.GetSomeMonthBill(year,month, weChatBillType).GetAwaiter().GetResult();
            var result = new PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto>
            {
                Items = data.Item1.Skip((pageIndex - 1) * pageSize).Take(pageSize).As<List<WxPayBillDetailDto>>(),
                Count = data.Item1.Count(),
                PageIndex = pageIndex,
                PageSize = pageSize,
                Statistics = data.Item2.As<WxPayBillStatisticsDto>()
            };
            return result;
        }
        public PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto> GetSomeYearBill(int year, WeChatBillType weChatBillType, int pageIndex, int pageSize)
        {

            var data = this.wxPayBillData.GetSomeYearBill(year, weChatBillType).GetAwaiter().GetResult();
            var result = new PageableList<WxPayBillDetailDto, WxPayBillStatisticsDto>
            {
                Items = data.Item1.Skip((pageIndex - 1) * pageSize).Take(pageSize).As<List<WxPayBillDetailDto>>(),
                Count = data.Item1.Count(),
                PageIndex = pageIndex,
                PageSize = pageSize,
                Statistics = data.Item2.As<WxPayBillStatisticsDto>()
            };
            return result;
        }

        #region 微信对账单数据处理
        #region 获取微信对账单数据
        /// <summary>
        /// 获取微信对账单数据
        /// </summary>
        /// <param name="result">账单数据</param>
        /// <param name="billDate">账单日期</param>
        /// <param name="billType">对账单类型</param>
        /// <param name="billStatistics">返回对账单统计</param>
        /// <returns></returns>
        private List<WxPayBillDetailEntity> GetBillResult(string result, DateTime billDate, WeChatBillType billType, out WxPayBillStatisticsEntity billStatistics)
        {
            string[] valArr = result.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (valArr.Length ==0)
            {
                billStatistics = null;
                return new List<WxPayBillDetailEntity>();
            }
            List<WxPayBillDetailEntity> list = GetTodayAllBillResult(valArr);
            billStatistics = new WxPayBillStatisticsEntity();
            if (list.Any())
            {
                string[] billSumTitle = valArr[valArr.Length - 2].Split(',');
                string[] billSumResult = valArr[valArr.Length - 1].Split(',');

                for (int i = 0; i < billSumTitle.Length; i++)
                {
                    string value = billSumResult[i].TrimStart('`');
                    switch (billSumTitle[i])
                    {
                        case "总交易单数":
                            billStatistics.TradeOrderCount = int.Parse(value);
                            break;
                        case "应结订单总金额":
                            billStatistics.PayOrderTotal = decimal.Parse(value);
                            break;
                        case "退款总金额":
                            billStatistics.RefundTotal = decimal.Parse(value);
                            break;
                        case "充值券退款总金额":
                            billStatistics.RechargeRefundTotal = decimal.Parse(value);
                            break;
                        case "手续费总金额":
                            billStatistics.HandlingFeeTotal = decimal.Parse(value);
                            break;
                        case "订单总金额":
                            billStatistics.OrderTotal = decimal.Parse(value);
                            break;
                        case "申请退款总金额":
                            billStatistics.ApplyRefundTotal = decimal.Parse(value);
                            break;
                    }
                }
                billStatistics.TradeType = billType.ToString();
                billStatistics.TradeTypeStr = billType.ToString();
                billStatistics.ActualReceiveTotal = billStatistics.PayOrderTotal - billStatistics.HandlingFeeTotal;
                billStatistics.ApplyRefundCount = list.Count(p => p.TradeStatus == "REFUND");
                billStatistics.TradeSuccessCount = list.Count(p => p.TradeStatus == "SUCCESS");
                billStatistics.TradeDate = billDate.Date;
                billStatistics.CreateTime = DateTime.Now;
            }
            return list;
        }
        #endregion

        #region 获取对账单清单数据
        /// <summary>
        /// 获取对账单清单数据
        /// </summary>
        /// <param name="data">对账单数据</param>
        /// <returns></returns>
        private List<WxPayBillDetailEntity> GetTodayAllBillResult(string[] data)
        {
            string[] billTitle = data[0].Split(',');

            List<WxPayBillDetailEntity> bills = new List<WxPayBillDetailEntity>();
            for (int i = 1; i < data.Length - 2; i++)
            {
                string[] billResult = data[i].Split(',');
                WxPayBillDetailEntity bill = new WxPayBillDetailEntity();
                for (int j = 0; j < billTitle.Length; j++)
                {
                    string value = billResult[j].TrimStart('`');
                    switch (billTitle[j])
                    {
                        case "交易时间":
                            bill.TradeTime = DateTime.Parse(value);
                            bill.TradeDate = bill.TradeTime.Date;
                            break;
                        case "公众账号ID":
                            bill.AppId = value;
                            bill.AppName = accountDic[value];
                            break;
                        case "商户号":
                            bill.MchId = value;
                            break;
                        case "特约商户号":
                            bill.SpecificMchId = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "设备号":
                            bill.DeviceNo = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "微信订单号":
                            bill.WxOrderNo = value;
                            break;
                        case "商户订单号":
                            bill.PaymentRecordId = Convert.ToInt64(value);
                            break;
                        case "用户标识":
                            bill.WxUserNo = value;
                            break;
                        case "交易类型":
                            bill.TradeType = value;
                            bill.TradeTypeStr = value;
                            break;
                        case "交易状态":
                            bill.TradeStatus = value;
                            bill.TradeStatusStr = value == "SUCCESS" ? "成功" : value == "REFUND" ? "转入退款" : "已撤销";
                            break;
                        case "付款银行":
                            bill.PayerBank = value;
                            bill.PayerBankStr = bankDic[value];
                            break;
                        case "货币种类":
                            bill.CurrencyCode = value;
                            bill.CurrencyCodeStr = "人民币";
                            break;
                        case "应结订单金额":
                            bill.PaySingleAmount = decimal.Parse(value);
                            break;
                        case "代金券金额":
                            bill.CouponAmount = decimal.Parse(value);
                            break;
                        case "退款申请时间":
                            bill.ApplyRefundTime = string.IsNullOrWhiteSpace(value) ? new Nullable<DateTime>() : DateTime.Parse(value);
                            break;
                        case "退款成功时间":
                            bill.RefundSuccessTime = string.IsNullOrWhiteSpace(value) ? new Nullable<DateTime>() : DateTime.Parse(value);
                            break;
                        case "微信退款单号":
                            bill.RefundOrderNo = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "商户退款单号":
                            bill.MchRefundOrderNo = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "退款金额":
                            bill.RefundAmount = decimal.Parse(value) == 0 ? new Nullable<decimal>() : decimal.Parse(value);
                            break;
                        case "充值券退款金额":
                            bill.RechargeRefundAmount = decimal.Parse(value) == 0 ? new Nullable<decimal>() : decimal.Parse(value);
                            break;
                        case "退款类型":
                            bill.RefundType = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "退款状态":
                            bill.RefundStatus = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "商品名称":
                            bill.GoodsName = value;
                            break;
                        case "商户数据包":
                            bill.MchDataPackage = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "手续费":
                            bill.HandlingFee = decimal.Parse(value);
                            break;
                        case "费率":
                            bill.FeeRate = Convert.ToInt32(double.Parse(value.Replace("%", "")) * 10);
                            bill.FeeRateStr = value;
                            break;
                        case "费率备注":
                            bill.FeeRateRemark = string.IsNullOrWhiteSpace(value) ? null : value;
                            break;
                        case "订单金额":
                            bill.OrderAmount = decimal.Parse(value);
                            break;
                        case "申请退款金额":
                            bill.ApplyRefundAmount = decimal.Parse(value) == 0 ? new Nullable<decimal>() : decimal.Parse(value);
                            break;
                        default:
                            break;
                    }
                }
                bill.ActualReceiveAmount = bill.OrderAmount - bill.HandlingFee;
                bill.CreateTime = DateTime.Now;
                bills.Add(bill);
            }
            return bills;
        }
        #endregion

        #region 初始化微信银行码映射名称字典
        /// <summary>
        /// 初始化微信银行码映射名称字典
        /// </summary>
        private void GetWxPayBankName()
        {
            bankDic.Add("ICBC_DEBIT", "工商银行（借记卡）");
            bankDic.Add("ICBC_CREDIT", "工商银行（信用卡）");
            bankDic.Add("ABC_DEBIT", "农业银行（借记卡）");
            bankDic.Add("ABC_CREDIT", "农业银行（信用卡）");
            bankDic.Add("PSBC_CREDIT", "邮储银行（信用卡）");
            bankDic.Add("PSBC_DEBIT", "邮储银行（借记卡）");
            bankDic.Add("CCB_DEBIT", "建设银行（借记卡）");
            bankDic.Add("CCB_CREDIT", "建设银行（信用卡）");
            bankDic.Add("CMB_DEBIT", "招商银行（借记卡）");
            bankDic.Add("CMB_CREDIT", "招商银行（信用卡）");
            bankDic.Add("BOC_DEBIT", "中国银行（借记卡）");
            bankDic.Add("BOC_CREDIT", "中国银行（信用卡）");
            bankDic.Add("COMM_DEBIT", "交通银行（借记卡）");
            bankDic.Add("COMM_CREDIT", "交通银行（信用卡）");
            bankDic.Add("SPDB_DEBIT", "浦发银行（借记卡）");
            bankDic.Add("SPDB_CREDIT", "浦发银行（信用卡）");
            bankDic.Add("GDB_DEBIT", "广发银行（借记卡）");
            bankDic.Add("GDB_CREDIT", "广发银行（信用卡）");
            bankDic.Add("CMBC_DEBIT", "民生银行（借记卡）");
            bankDic.Add("CMBC_CREDIT", "民生银行（信用卡）");
            bankDic.Add("PAB_DEBIT", "平安银行（借记卡）");
            bankDic.Add("PAB_CREDIT", "平安银行（信用卡）");
            bankDic.Add("CEB_DEBIT", "光大银行（借记卡）");
            bankDic.Add("CEB_CREDIT", "光大银行（信用卡）");
            bankDic.Add("CIB_DEBIT", "兴业银行（借记卡）");
            bankDic.Add("CIB_CREDIT", "兴业银行（信用卡）");
            bankDic.Add("CITIC_DEBIT", "中信银行（借记卡）");
            bankDic.Add("CITIC_CREDIT", "中信银行（信用卡）");
            bankDic.Add("BOSH_DEBIT", "上海银行（借记卡）");
            bankDic.Add("BOSH_CREDIT", "上海银行（信用卡）");
            bankDic.Add("AHRCUB_CREDIT", "安徽省农村信用社联合社（信用卡）");
            bankDic.Add("AHRCUB_DEBIT", "安徽省农村信用社联合社（借记卡）");
            bankDic.Add("AIB_DEBIT", "百信银行（借记卡）");
            bankDic.Add("ASCB_DEBIT", "鞍山银行（借记卡）");
            bankDic.Add("ATRB_DEBIT", "盘山安泰村镇银行（借记卡）");
            bankDic.Add("BCZ_CREDIT", "沧州银行（信用卡）");
            bankDic.Add("BCZ_DEBIT", "沧州银行（借记卡）");
            bankDic.Add("BDB_DEBIT", "保定银行（借记卡）");
            bankDic.Add("BEEB_CREDIT", "鄞州银行（信用卡）");
            bankDic.Add("BEEB_DEBIT", "鄞州银行（借记卡）");
            bankDic.Add("BGZB_DEBIT", "贵州银行（借记卡）");
            bankDic.Add("BHB_CREDIT", "河北银行（信用卡）");
            bankDic.Add("BHB_DEBIT", "河北银行（借记卡）");
            bankDic.Add("BJRCB_CREDIT", "北京农商行（信用卡）");
            bankDic.Add("BJRCB_DEBIT", "北京农商行（借记卡）");
            bankDic.Add("BNC_CREDIT", "江西银行（信用卡）");
            bankDic.Add("BNC_DEBIT", "江西银行（借记卡）");
            bankDic.Add("BOB_CREDIT", "北京银行（信用卡）");
            bankDic.Add("BOB_DEBIT", "北京银行（借记卡）");
            bankDic.Add("BOBBG_CREDIT", "北部湾银行（信用卡）");
            bankDic.Add("BOBBG_DEBIT", "北部湾银行（借记卡）");
            bankDic.Add("BOCD_DEBIT", "成都银行（借记卡）");
            bankDic.Add("BOCDB_DEBIT", "承德银行（借记卡）");
            bankDic.Add("BOCFB_DEBIT", "中银富登村镇银行（借记卡）");
            bankDic.Add("BOCTS_DEBIT", "焦作中旅银行（借记卡）");
            bankDic.Add("BOD_CREDIT", "东莞银行（信用卡）");
            bankDic.Add("BOD_DEBIT", "东莞银行（借记卡）");
            bankDic.Add("BOFS_DEBIT", "抚顺银行（借记卡）");
            bankDic.Add("BOHN_DEBIT", "海南银行（借记卡）");
            bankDic.Add("BOIMCB_CREDIT", "内蒙古银行（信用卡）");
            bankDic.Add("BOIMCB_DEBIT", "内蒙古银行（借记卡）");
            bankDic.Add("BOJN_DEBIT", "济宁银行（借记卡）");
            bankDic.Add("BOJX_DEBIT", "嘉兴银行（借记卡）");
            bankDic.Add("BOLB_DEBIT", "洛阳银行（借记卡）");
            bankDic.Add("BOLFB_DEBIT", "廊坊银行（借记卡）");
            bankDic.Add("BONX_CREDIT", "宁夏银行（信用卡）");
            bankDic.Add("BONX_DEBIT", "宁夏银行（借记卡）");
            bankDic.Add("BOPDS_DEBIT", "平顶山银行（借记卡）");
            bankDic.Add("BOPJ_DEBIT", "盘锦银行（借记卡）");
            bankDic.Add("BOQHB_CREDIT", "青海银行（信用卡）");
            bankDic.Add("BOQHB_DEBIT", "青海银行（借记卡）");
            bankDic.Add("BOSXB_DEBIT", "绍兴银行（借记卡）");
            bankDic.Add("BOSZS_DEBIT", "石嘴山银行（借记卡）");
            bankDic.Add("BOTSB_DEBIT", "唐山银行（借记卡）");
            bankDic.Add("BOZ_CREDIT", "张家口银行（信用卡）");
            bankDic.Add("BOZ_DEBIT", "张家口银行（借记卡）");
            bankDic.Add("BSB_CREDIT", "包商银行（信用卡）");
            bankDic.Add("BSB_DEBIT", "包商银行（借记卡）");
            bankDic.Add("BYK_DEBIT", "营口银行（借记卡）");
            bankDic.Add("CBHB_DEBIT", "渤海银行（借记卡）");
            bankDic.Add("CCAB_CREDIT", "长安银行（信用卡）");
            bankDic.Add("CCAB_DEBIT", "长安银行（借记卡）");
            bankDic.Add("CDRCB_DEBIT", "成都农商银行（借记卡）");
            bankDic.Add("CITIB_CREDIT", "花旗银行（信用卡）");
            bankDic.Add("CITIB_DEBIT", "花旗银行（借记卡）");
            bankDic.Add("CJCCB_DEBIT", "江苏长江商业银行（借记卡）");
            bankDic.Add("CQB_CREDIT", "重庆银行（信用卡）");
            bankDic.Add("CQB_DEBIT", "重庆银行（借记卡）");
            bankDic.Add("CQRCB_CREDIT", "重庆农村商业银行（信用卡）");
            bankDic.Add("CQRCB_DEBIT", "重庆农村商业银行（借记卡）");
            bankDic.Add("CQTGB_DEBIT", "重庆三峡银行（借记卡）");
            bankDic.Add("CRB_CREDIT", "珠海华润银行（信用卡）");
            bankDic.Add("CRB_DEBIT", "珠海华润银行（借记卡）");
            bankDic.Add("CSCB_CREDIT", "长沙银行（信用卡）");
            bankDic.Add("CSCB_DEBIT", "长沙银行（借记卡）");
            bankDic.Add("CSRCB_CREDIT", "常熟农商银行（信用卡）");
            bankDic.Add("CSRCB_DEBIT", "常熟农商银行（借记卡）");
            bankDic.Add("CSXB_DEBIT", "三湘银行（借记卡）");
            bankDic.Add("CYCB_CREDIT", "朝阳银行（信用卡）");
            bankDic.Add("CYCB_DEBIT", "朝阳银行（借记卡）");
            bankDic.Add("CZB_CREDIT", "浙商银行（信用卡）");
            bankDic.Add("CZB_DEBIT", "浙商银行（借记卡）");
            bankDic.Add("CZCB_CREDIT", "稠州银行（信用卡）");
            bankDic.Add("CZCB_DEBIT", "稠州银行（借记卡）");
            bankDic.Add("CZCCB_DEBIT", "长治银行（借记卡）");
            bankDic.Add("DANDONGB_CREDIT", "丹东银行（信用卡）");
            bankDic.Add("DANDONGB_DEBIT", "丹东银行（借记卡）");
            bankDic.Add("DBSB_DEBIT", "星展银行（借记卡）");
            bankDic.Add("DCSFRB_DEBIT", "大城舜丰村镇银行（借记卡）");
            bankDic.Add("DHDYB_DEBIT", "德惠敦银村镇银行（借记卡）");
            bankDic.Add("DHRB_DEBIT", "调兵山惠民村镇银行（借记卡）");
            bankDic.Add("DLB_CREDIT", "大连银行（信用卡）");
            bankDic.Add("DLB_DEBIT", "大连银行（借记卡）");
            bankDic.Add("DLRCB_DEBIT", "大连农商行（借记卡）");
            bankDic.Add("DRCB_CREDIT", "东莞农商银行（信用卡）");
            bankDic.Add("DRCB_DEBIT", "东莞农商银行（借记卡）");
            bankDic.Add("DSB_DEBIT", "大新银行（借记卡）");
            bankDic.Add("DTCCB_DEBIT", "大同银行（借记卡）");
            bankDic.Add("DYB_CREDIT", "东营银行（信用卡）");
            bankDic.Add("DYB_DEBIT", "东营银行（借记卡）");
            bankDic.Add("DYCCB_DEBIT", "长城华西银行（借记卡）");
            bankDic.Add("DYLSB_DEBIT", "东营莱商村镇银行（借记卡）");
            bankDic.Add("DZB_DEBIT", "德州银行（借记卡）");
            bankDic.Add("DZCCB_DEBIT", "达州银行（借记卡）");
            bankDic.Add("EDRB_DEBIT", "鼎业村镇银行（借记卡）");
            bankDic.Add("ESUNB_DEBIT", "玉山银行（借记卡）");
            bankDic.Add("FBB_DEBIT", "富邦华一银行（借记卡）");
            bankDic.Add("FDB_CREDIT", "富滇银行（信用卡）");
            bankDic.Add("FDB_DEBIT", "富滇银行（借记卡）");
            bankDic.Add("FJHXB_CREDIT", "福建海峡银行（信用卡）");
            bankDic.Add("FJHXB_DEBIT", "福建海峡银行（借记卡）");
            bankDic.Add("FJNX_CREDIT", "福建农信银行（信用卡）");
            bankDic.Add("FJNX_DEBIT", "福建农信银行（借记卡）");
            bankDic.Add("FUXINB_CREDIT", "阜新银行（信用卡）");
            bankDic.Add("FUXINB_DEBIT", "阜新银行（借记卡）");
            bankDic.Add("FXLZB_DEBIT", "费县梁邹村镇银行（借记卡）");
            bankDic.Add("GADRB_DEBIT", "贵安新区发展村镇银行（借记卡）");
            bankDic.Add("GDHX_DEBIT", "广东华兴银行（借记卡）");
            bankDic.Add("GDNYB_CREDIT", "南粤银行（信用卡）");
            bankDic.Add("GDNYB_DEBIT", "南粤银行（借记卡）");
            bankDic.Add("GDRCU_DEBIT", "广东农信银行（借记卡）");
            bankDic.Add("GLB_CREDIT", "桂林银行（信用卡）");
            bankDic.Add("GLB_DEBIT", "桂林银行（借记卡）");
            bankDic.Add("GLGMCB_DEBIT", "桂林国民村镇银行（借记卡）");
            bankDic.Add("GRCB_CREDIT", "广州农商银行（信用卡）");
            bankDic.Add("GRCB_DEBIT", "广州农商银行（借记卡）");
            bankDic.Add("GSB_DEBIT", "甘肃银行（借记卡）");
            bankDic.Add("GSNX_DEBIT", "甘肃农信（借记卡）");
            bankDic.Add("GSRB_DEBIT", "广阳舜丰村镇银行（借记卡）");
            bankDic.Add("GXNX_CREDIT", "广西农信（信用卡）");
            bankDic.Add("GXNX_DEBIT", "广西农信（借记卡）");
            bankDic.Add("GYCB_CREDIT", "贵阳银行（信用卡）");
            bankDic.Add("GYCB_DEBIT", "贵阳银行（借记卡）");
            bankDic.Add("GZCB_CREDIT", "广州银行（信用卡）");
            bankDic.Add("GZCB_DEBIT", "广州银行（借记卡）");
            bankDic.Add("GZCCB_CREDIT", "赣州银行（信用卡）");
            bankDic.Add("GZCCB_DEBIT", "赣州银行（借记卡）");
            bankDic.Add("GZNX_DEBIT", "贵州农信（借记卡）");
            bankDic.Add("HAINNX_CREDIT", "海南农信（信用卡）");
            bankDic.Add("HAINNX_DEBIT", "海南农信（借记卡）");
            bankDic.Add("HANAB_DEBIT", "韩亚银行（借记卡）");
            bankDic.Add("HBCB_CREDIT", "湖北银行（信用卡）");
            bankDic.Add("HBCB_DEBIT", "湖北银行（借记卡）");
            bankDic.Add("HBNX_CREDIT", "湖北农信（信用卡）");
            bankDic.Add("HBNX_DEBIT", "湖北农信（借记卡）");
            bankDic.Add("HDCB_DEBIT", "邯郸银行（借记卡）");
            bankDic.Add("HEBNX_DEBIT", "河北农信（借记卡）");
            bankDic.Add("HFB_CREDIT", "恒丰银行（信用卡）");
            bankDic.Add("HFB_DEBIT", "恒丰银行（借记卡）");
            bankDic.Add("HKB_CREDIT", "汉口银行（信用卡）");
            bankDic.Add("HKB_DEBIT", "汉口银行（借记卡）");
            bankDic.Add("HKBEA_CREDIT", "东亚银行（信用卡）");
            bankDic.Add("HKBEA_DEBIT", "东亚银行（借记卡）");
            bankDic.Add("HKUB_DEBIT", "海口联合农商银行（借记卡）");
            bankDic.Add("HLDCCB_DEBIT", "葫芦岛银行（借记卡）");
            bankDic.Add("HLDYB_DEBIT", "和龙敦银村镇银行（借记卡）");
            bankDic.Add("HLJRCUB_DEBIT", "黑龙江农信社（借记卡）");
            bankDic.Add("HMCCB_DEBIT", "哈密银行（借记卡）");
            bankDic.Add("HNNX_DEBIT", "河南农信（借记卡）");
            bankDic.Add("HRBB_CREDIT", "哈尔滨银行（信用卡）");
            bankDic.Add("HRBB_DEBIT", "哈尔滨银行（借记卡）");
            bankDic.Add("HRCB_DEBIT", "保德慧融村镇银行（借记卡）");
            bankDic.Add("HRXJB_CREDIT", "华融湘江银行（信用卡）");
            bankDic.Add("HRXJB_DEBIT", "华融湘江银行（借记卡）");
            bankDic.Add("HSB_CREDIT", "徽商银行（信用卡）");
            bankDic.Add("HSB_DEBIT", "徽商银行（借记卡）");
            bankDic.Add("HSBC_DEBIT", "恒生银行（借记卡）");
            bankDic.Add("HSBCC_CREDIT", "汇丰银行（信用卡）");
            bankDic.Add("HSBCC_DEBIT", "汇丰银行（借记卡）");
            bankDic.Add("HSCB_DEBIT", "衡水银行（借记卡）");
            bankDic.Add("HUIHEB_DEBIT", "新疆汇和银行（借记卡）");
            bankDic.Add("HUNNX_DEBIT", "湖南农信（借记卡）");
            bankDic.Add("HUSRB_DEBIT", "湖商村镇银行（借记卡）");
            bankDic.Add("HXB_CREDIT", "华夏银行（信用卡）");
            bankDic.Add("HXB_DEBIT", "华夏银行（借记卡）");
            bankDic.Add("HZB_CREDIT", "杭州银行（信用卡）");
            bankDic.Add("HZB_DEBIT", "杭州银行（借记卡）");
            bankDic.Add("HZCCB_DEBIT", "湖州银行（借记卡）");
            bankDic.Add("IBKB_DEBIT", "企业银行（借记卡）");
            bankDic.Add("JCB_DEBIT", "晋城银行（借记卡）");
            bankDic.Add("JCBK_CREDIT", "晋城银行（信用卡）");
            bankDic.Add("JDHDB_DEBIT", "上海嘉定洪都村镇银行（借记卡）");
            bankDic.Add("JDZCCB_DEBIT", "景德镇市商业银行（借记卡）");
            bankDic.Add("JHCCB_CREDIT", "金华银行（信用卡）");
            bankDic.Add("JHCCB_DEBIT", "金华银行（借记卡）");
            bankDic.Add("JJCCB_CREDIT", "九江银行（信用卡）");
            bankDic.Add("JJCCB_DEBIT", "九江银行（借记卡）");
            bankDic.Add("JLB_CREDIT", "吉林银行（信用卡）");
            bankDic.Add("JLB_DEBIT", "吉林银行（借记卡）");
            bankDic.Add("JLNX_DEBIT", "吉林农信（借记卡）");
            bankDic.Add("JNRCB_CREDIT", "江南农商行（信用卡）");
            bankDic.Add("JNRCB_DEBIT", "江南农商行（借记卡）");
            bankDic.Add("JRCB_CREDIT", "江阴农商行（信用卡）");
            bankDic.Add("JRCB_DEBIT", "江阴农商行（借记卡）");
            bankDic.Add("JSB_CREDIT", "江苏银行（信用卡）");
            bankDic.Add("JSB_DEBIT", "江苏银行（借记卡）");
            bankDic.Add("JSHB_CREDIT", "晋商银行（信用卡）");
            bankDic.Add("JSHB_DEBIT", "晋商银行（借记卡）");
            bankDic.Add("JSNX_CREDIT", "江苏农信（信用卡）");
            bankDic.Add("JSNX_DEBIT", "江苏农信（借记卡）");
            bankDic.Add("JUFENGB_DEBIT", "临朐聚丰村镇银行（借记卡）");
            bankDic.Add("JXB_DEBIT", "西昌金信村镇银行（借记卡）");
            bankDic.Add("JXNXB_DEBIT", "江西农信（借记卡）");
            bankDic.Add("JZB_CREDIT", "晋中银行（信用卡）");
            bankDic.Add("JZB_DEBIT", "晋中银行（借记卡）");
            bankDic.Add("JZCB_CREDIT", "锦州银行（信用卡）");
            bankDic.Add("JZCB_DEBIT", "锦州银行（借记卡）");
            bankDic.Add("KCBEB_DEBIT", "天津金城银行（借记卡）");
            bankDic.Add("KLB_CREDIT", "昆仑银行（信用卡）");
            bankDic.Add("KLB_DEBIT", "昆仑银行（借记卡）");
            bankDic.Add("KRCB_DEBIT", "昆山农商（借记卡）");
            bankDic.Add("KSHB_DEBIT", "梅州客商银行（借记卡）");
            bankDic.Add("KUERLECB_DEBIT", "库尔勒市商业银行（借记卡）");
            bankDic.Add("LCYRB_DEBIT", "陵城圆融村镇银行（借记卡）");
            bankDic.Add("LICYRB_DEBIT", "历城圆融村镇银行（借记卡）");
            bankDic.Add("LJB_DEBIT", "龙江银行（借记卡）");
            bankDic.Add("LLB_DEBIT", "山东兰陵村镇银行（借记卡）");
            bankDic.Add("LLHZCB_DEBIT", "柳林汇泽村镇银行（借记卡）");
            bankDic.Add("LNNX_DEBIT", "辽宁农信（借记卡）");
            bankDic.Add("LPCB_DEBIT", "凉山州商业银行（借记卡）");
            bankDic.Add("LPSBLVB_DEBIT", "钟山凉都村镇银行（借记卡）");
            bankDic.Add("LSB_CREDIT", "临商银行（信用卡）");
            bankDic.Add("LSB_DEBIT", "临商银行（借记卡）");
            bankDic.Add("LSCCB_DEBIT", "乐山市商业银行（借记卡）");
            bankDic.Add("LUZB_DEBIT", "柳州银行（借记卡）");
            bankDic.Add("LWB_DEBIT", "莱商银行（借记卡）");
            bankDic.Add("LYYHB_DEBIT", "辽阳银行（借记卡）");
            bankDic.Add("LZB_CREDIT", "兰州银行（信用卡）");
            bankDic.Add("LZB_DEBIT", "兰州银行（借记卡）");
            bankDic.Add("LZCCB_DEBIT", "泸州市商业银行（借记卡）");
            bankDic.Add("MHBRB_DEBIT", "闵行上银村镇银行（借记卡）");
            bankDic.Add("MINTAIB_CREDIT", "民泰银行（信用卡）");
            bankDic.Add("MINTAIB_DEBIT", "民泰银行（借记卡）");
            bankDic.Add("MPJDRB_DEBIT", "牟平胶东村镇银行（借记卡）");
            bankDic.Add("MYCCB_DEBIT", "绵阳市商业银行（借记卡）");
            bankDic.Add("NBCB_CREDIT", "宁波银行（信用卡）");
            bankDic.Add("NBCB_DEBIT", "宁波银行（借记卡）");
            bankDic.Add("NCB_DEBIT", "宁波通商银行（借记卡）");
            bankDic.Add("NCBCB_DEBIT", "南洋商业银行（借记卡）");
            bankDic.Add("NCCB_DEBIT", "四川天府银行（借记卡）");
            bankDic.Add("NJCB_CREDIT", "南京银行（信用卡）");
            bankDic.Add("NJCB_DEBIT", "南京银行（借记卡）");
            bankDic.Add("NJJDRB_DEBIT", "宁津胶东村镇银行（借记卡）");
            bankDic.Add("NJXLRB_DEBIT", "内江兴隆村镇银行（借记卡）");
            bankDic.Add("NMGNX_DEBIT", "内蒙古农信（借记卡）");
            bankDic.Add("NNGMB_DEBIT", "南宁江南国民村镇银行（借记卡）");
            bankDic.Add("NUB_DEBIT", "辽宁振兴银行（借记卡）");
            bankDic.Add("NYCCB_DEBIT", "南阳村镇银行（借记卡）");
            bankDic.Add("OCBCWHCB_DEBIT", "华侨永亨银行（借记卡）");
            bankDic.Add("OHVB_DEBIT", "鄂托克旗汇泽村镇银行（借记卡）");
            bankDic.Add("ORDOSB_CREDIT", "鄂尔多斯银行（信用卡）");
            bankDic.Add("ORDOSB_DEBIT", "鄂尔多斯银行（借记卡）");
            bankDic.Add("PBDLRB_DEBIT", "平坝鼎立村镇银行（借记卡）");
            bankDic.Add("PJDWHFB_DEBIT", "大洼恒丰村镇银行（借记卡）");
            bankDic.Add("PJJYRB_DEBIT", "浦江嘉银村镇银行（借记卡）");
            bankDic.Add("PZHCCB_DEBIT", "攀枝花银行（借记卡）");
            bankDic.Add("QDCCB_CREDIT", "青岛银行（信用卡）");
            bankDic.Add("QDCCB_DEBIT", "青岛银行（借记卡）");
            bankDic.Add("QHDB_DEBIT", "秦皇岛银行（借记卡）");
            bankDic.Add("QHJDRB_DEBIT", "齐河胶东村镇银行（借记卡）");
            bankDic.Add("QHNX_DEBIT", "青海农信（借记卡）");
            bankDic.Add("QJSYB_DEBIT", "衢江上银村镇银行（借记卡）");
            bankDic.Add("QLB_CREDIT", "齐鲁银行（信用卡）");
            bankDic.Add("QLB_DEBIT", "齐鲁银行（借记卡）");
            bankDic.Add("QLVB_DEBIT", "青隆村镇银行（借记卡）");
            bankDic.Add("QSB_CREDIT", "齐商银行（信用卡）");
            bankDic.Add("QSB_DEBIT", "齐商银行（借记卡）");
            bankDic.Add("QZCCB_CREDIT", "泉州银行（信用卡）");
            bankDic.Add("QZCCB_DEBIT", "泉州银行（借记卡）");
            bankDic.Add("RHCB_DEBIT", "长子县融汇村镇银行（借记卡）");
            bankDic.Add("RQCZB_DEBIT", "任丘村镇银行（借记卡）");
            bankDic.Add("RXYHB_DEBIT", "瑞信村镇银行（借记卡）");
            bankDic.Add("RZB_DEBIT", "日照银行（借记卡）");
            bankDic.Add("SCB_CREDIT", "渣打银行（信用卡）");
            bankDic.Add("SCB_DEBIT", "渣打银行（借记卡）");
            bankDic.Add("SCNX_DEBIT", "四川农信（借记卡）");
            bankDic.Add("SDEB_CREDIT", "顺德农商行（信用卡）");
            bankDic.Add("SDEB_DEBIT", "顺德农商行（借记卡）");
            bankDic.Add("SDRCU_DEBIT", "山东农信（借记卡）");
            bankDic.Add("SHHJB_DEBIT", "商河汇金村镇银行（借记卡）");
            bankDic.Add("SHINHAN_DEBIT", "新韩银行（借记卡）");
            bankDic.Add("SHRB_DEBIT", "上海华瑞银行（借记卡）");
            bankDic.Add("SJB_CREDIT", "盛京银行（信用卡）");
            bankDic.Add("SJB_DEBIT", "盛京银行（借记卡）");
            bankDic.Add("SNB_DEBIT", "苏宁银行（借记卡）");
            bankDic.Add("SNCCB_DEBIT", "遂宁银行（借记卡）");
            bankDic.Add("SPDYB_DEBIT", "四平铁西敦银村镇银行（借记卡）");
            bankDic.Add("SRB_DEBIT", "上饶银行（借记卡）");
            bankDic.Add("SRCB_CREDIT", "上海农商银行（信用卡）");
            bankDic.Add("SRCB_DEBIT", "上海农商银行（借记卡）");
            bankDic.Add("SUZB_CREDIT", "苏州银行（信用卡）");
            bankDic.Add("SUZB_DEBIT", "苏州银行（借记卡）");
            bankDic.Add("SXNX_DEBIT", "山西农信（借记卡）");
            bankDic.Add("SXXH_DEBIT", "陕西信合（借记卡）");
            bankDic.Add("SZRCB_CREDIT", "深圳农商银行（信用卡）");
            bankDic.Add("SZRCB_DEBIT", "深圳农商银行（借记卡）");
            bankDic.Add("TACCB_CREDIT", "泰安银行（信用卡）");
            bankDic.Add("TACCB_DEBIT", "泰安银行（借记卡）");
            bankDic.Add("TCRCB_DEBIT", "太仓农商行（借记卡）");
            bankDic.Add("TJB_CREDIT", "天津银行（信用卡）");
            bankDic.Add("TJB_DEBIT", "天津银行（借记卡）");
            bankDic.Add("TJBHB_CREDIT", "天津滨海农商行（信用卡）");
            bankDic.Add("TJBHB_DEBIT", "天津滨海农商行（借记卡）");
            bankDic.Add("TJHMB_DEBIT", "天津华明村镇银行（借记卡）");
            bankDic.Add("TJNHVB_DEBIT", "天津宁河村镇银行（借记卡）");
            bankDic.Add("TLB_DEBIT", "铁岭银行（借记卡）");
            bankDic.Add("TLVB_DEBIT", "铁岭新星村镇银行（借记卡）");
            bankDic.Add("TMDYB_DEBIT", "图们敦银村镇银行（借记卡）");
            bankDic.Add("TRCB_CREDIT", "天津农商（信用卡）");
            bankDic.Add("TRCB_DEBIT", "天津农商（借记卡）");
            bankDic.Add("TZB_CREDIT", "台州银行（信用卡）");
            bankDic.Add("TZB_DEBIT", "台州银行（借记卡）");
            bankDic.Add("UOB_DEBIT", "大华银行（借记卡）");
            bankDic.Add("URB_DEBIT", "联合村镇银行（借记卡）");
            bankDic.Add("VBCB_DEBIT", "村镇银行（借记卡）");
            bankDic.Add("WACZB_DEBIT", "武安村镇银行（借记卡）");
            bankDic.Add("WB_DEBIT", "友利银行（借记卡）");
            bankDic.Add("WEB_DEBIT", "微众银行（借记卡）");
            bankDic.Add("WEGOB_DEBIT", "蓝海银行（借记卡）");
            bankDic.Add("WFB_CREDIT", "潍坊银行（信用卡）");
            bankDic.Add("WFB_DEBIT", "潍坊银行（借记卡）");
            bankDic.Add("WHB_CREDIT", "威海商业银行（信用卡）");
            bankDic.Add("WHB_DEBIT", "威海商业银行（借记卡）");
            bankDic.Add("WHRC_CREDIT", "武汉农商行（信用卡）");
            bankDic.Add("WHRC_DEBIT", "武汉农商行（借记卡）");
            bankDic.Add("WHRYVB_DEBIT", "芜湖圆融村镇银行（借记卡）");
            bankDic.Add("WJRCB_CREDIT", "吴江农商行（信用卡）");
            bankDic.Add("WJRCB_DEBIT", "吴江农商行（借记卡）");
            bankDic.Add("WLMQB_CREDIT", "乌鲁木齐银行（信用卡）");
            bankDic.Add("WLMQB_DEBIT", "乌鲁木齐银行（借记卡）");
            bankDic.Add("WRCB_CREDIT", "无锡农商行（信用卡）");
            bankDic.Add("WRCB_DEBIT", "无锡农商行（借记卡）");
            bankDic.Add("WUHAICB_DEBIT", "乌海银行（借记卡）");
            bankDic.Add("WZB_CREDIT", "温州银行（信用卡）");
            bankDic.Add("WZB_DEBIT", "温州银行（借记卡）");
            bankDic.Add("WZMSB_DEBIT", "温州民商（借记卡）");
            bankDic.Add("XAB_CREDIT", "西安银行（信用卡）");
            bankDic.Add("XAB_DEBIT", "西安银行（借记卡）");
            bankDic.Add("XCXPB_DEBIT", "许昌新浦村镇银行（借记卡）");
            bankDic.Add("XHB_DEBIT", "大连鑫汇村镇银行（借记卡）");
            bankDic.Add("XHNMB_DEBIT", "安顺西航南马村镇银行（借记卡）");
            bankDic.Add("XIB_DEBIT", "厦门国际银行（借记卡）");
            bankDic.Add("XINANB_DEBIT", "安徽新安银行（借记卡）");
            bankDic.Add("XJB_DEBIT", "新疆银行（借记卡）");
            bankDic.Add("XJJDRB_DEBIT", "夏津胶东村镇银行（借记卡）");
            bankDic.Add("XJRCCB_DEBIT", "新疆农信银行（借记卡）");
            bankDic.Add("XMCCB_CREDIT", "厦门银行（信用卡）");
            bankDic.Add("XMCCB_DEBIT", "厦门银行（借记卡）");
            bankDic.Add("XRTB_DEBIT", "元氏信融村镇银行（借记卡）");
            bankDic.Add("XTB_CREDIT", "邢台银行（信用卡）");
            bankDic.Add("XTB_DEBIT", "邢台银行（借记卡）");
            bankDic.Add("XWB_DEBIT", "新网银行（借记卡）");
            bankDic.Add("XXCB_DEBIT", "新乡银行（借记卡）");
            bankDic.Add("XXHZCB_DEBIT", "兴县汇泽村镇银行（借记卡）");
            bankDic.Add("XXRB_DEBIT", "新乡新兴村镇银行（借记卡）");
            bankDic.Add("XYPQZYCB_DEBIT", "信阳平桥中原村镇银行（借记卡）");
            bankDic.Add("XZB_DEBIT", "西藏银行（借记卡）");
            bankDic.Add("YACCB_DEBIT", "雅安市商业银行（借记卡）");
            bankDic.Add("YBCCB_DEBIT", "宜宾商业银行（借记卡）");
            bankDic.Add("YKCB_DEBIT", "营口沿海银行（借记卡）");
            bankDic.Add("YLB_DEBIT", "亿联银行（借记卡）");
            bankDic.Add("YNHTB_CREDIT", "云南红塔银行（信用卡）");
            bankDic.Add("YNHTB_DEBIT", "云南红塔银行（借记卡）");
            bankDic.Add("YNRCCB_CREDIT", "云南农信（信用卡）");
            bankDic.Add("YNRCCB_DEBIT", "云南农信（借记卡）");
            bankDic.Add("YQCCB_DEBIT", "阳泉市商业银行（借记卡）");
            bankDic.Add("YQMYRB_DEBIT", "玉泉蒙银村镇银行（借记卡）");
            bankDic.Add("YRRCB_CREDIT", "黄河农商银行（信用卡）");
            bankDic.Add("YRRCB_DEBIT", "黄河农商银行（借记卡）");
            bankDic.Add("YTB_DEBIT", "烟台银行（借记卡）");
            bankDic.Add("YYBSCB_DEBIT", "沂源博商村镇银行（借记卡）");
            bankDic.Add("ZCRB_DEBIT", "遵义新蒲长征村镇银行（借记卡）");
            bankDic.Add("ZGB_DEBIT", "自贡银行（借记卡）");
            bankDic.Add("ZGCB_DEBIT", "北京中关村银行（借记卡）");
            bankDic.Add("ZHCB_DEBIT", "庄河汇通村镇银行（借记卡）");
            bankDic.Add("ZHQYTB_DEBIT", "沾化青云村镇银行（借记卡）");
            bankDic.Add("ZJB_DEBIT", "紫金农商银行（借记卡）");
            bankDic.Add("ZJLXRB_DEBIT", "兰溪越商银行（借记卡）");
            bankDic.Add("ZJRCUB_CREDIT", "浙江农信（信用卡）");
            bankDic.Add("ZJRCUB_DEBIT", "浙江农信（借记卡）");
            bankDic.Add("ZJTLCB_CREDIT", "浙江泰隆银行（信用卡）");
            bankDic.Add("ZJTLCB_DEBIT", "浙江泰隆银行（借记卡）");
            bankDic.Add("ZRCB_CREDIT", "张家港农商行（信用卡）");
            bankDic.Add("ZRCB_DEBIT", "张家港农商行（借记卡）");
            bankDic.Add("ZSXKCCB_DEBIT", "中山小榄村镇银行（借记卡）");
            bankDic.Add("ZYB_CREDIT", "中原银行（信用卡）");
            bankDic.Add("ZYB_DEBIT", "中原银行（借记卡）");
            bankDic.Add("ZZB_CREDIT", "郑州银行（信用卡）");
            bankDic.Add("ZZB_DEBIT", "郑州银行（借记卡）");
            bankDic.Add("ZZCCB_DEBIT", "枣庄银行（借记卡）");
            bankDic.Add("WPHK", "WPHK");
            bankDic.Add("QMF", "QMF");
            bankDic.Add("DINERSCLUD", "DINERSCLUD");
            bankDic.Add("MASTERCARD", "MASTERCARD");
            bankDic.Add("VISA", "VISA");
            bankDic.Add("CFT", "CFT");
            bankDic.Add("LQT", "LQT");
            bankDic.Add("AMERICANEXPRESS", "AMERICANEXPRESS");
            bankDic.Add("DISCOVER", "DISCOVER");
            bankDic.Add("OTHERS", "其他（银行卡以外）");
        }
        #endregion
        #region 初始化微信应用账号信息字典
        private void InitAccountInfo()
        {
            accountDic.Add(configuration["WeixinPay:ClientApp:APP_ID"], "ClientApp");
            accountDic.Add(configuration["WeixinPay:DriverApp:APP_ID"], "DriverApp");
            accountDic.Add(configuration["WeixinPay:PartnerApp:APP_ID"], "PartnerApp");
        }
        #endregion
        #endregion
    }
}
